using System;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using rpc_service.core.support.assembly.il;
using rpc_service.log;
using Microsoft.Extensions.Logging;

namespace rpc_service.core.support;

public class RPCMethodLoader
{
    private readonly ILogger<RPCClassLoader> _logger = Logger.GetLoggerFactory().CreateLogger<RPCClassLoader>();
    
    public bool MethodLoader(MethodInfo targetMethod)
    {
        if (!IsPRCMethod(targetMethod))
        {
            return false;
        }
        
        _logger.LogInformation("开始创建 方法 {} 的 RPC 代理方法",  targetMethod.Name);
        return true;
    }

    private bool IsPRCMethod(MethodInfo targetMethod)
    {
        if (targetMethod.GetCustomAttribute<RPCMethod>() == null)
        {
            return false;
        }
        
        return true;
    }
}